<?php
class Banks extends DataObject{
	static $db = array (
		"Name_en" => "Varchar(255)",
		"Position"=>"Int",
		"Status"=>"Boolean",
	);
	static $has_one = array (

	);
	static $searchable_fields = array (
		'Name_en'=> array('title'=>'Bank Name'),
		'Status' => array('title'=>'Is show?'),
	);
	/**
	 * Overload so that the default sort.
	 */

	static $summary_fields = array (
		'Name_en' => 'Bank Name',
		'Position' => 'Position',
		'getStatusName'=>"Is show"
	);
	function getStatusName()
	{
		if ($this->Status)
		{
			return 'Yes';
		}else	return 'No';
	}
	static $defaults = array(
		'Status' => 'True',
	);

	function getCMSFields($controller = null) {
		$fields = parent::getCMSFields();
		$TabVn= new Tab(_t('Career.TABCONTENTTITLEVN','Banks'),
			new TextField("Name_en", _t('Career.NAME_VI', 'Bank Name')),
			new NumericField("Position", _t('Career.NAME_VI', 'Position')),
			new CheckboxField("Status",_t('Career.Status', 'Is show'))
		);
		$fields = new FieldSet(new TabSet("Root",$TabVn));
		return $fields;
	}
	public function scaffoldSearchFields()
	{
		$fields = parent::scaffoldSearchFields();
		$drpStatus= Lib::dropdownYesNo('Status','Is show');
		$fields->replaceField('Status', $drpStatus);
		return $fields;
	}
	function getCMSValidator() {
		return new RequiredFields(array('Name_en'));
	}
	function canCreate() {return true;}
	function canEdit() {return true;}
	function canDelete() {return true;}
}